-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Add cached read and writes to stats and cost calculation for LiteLLM provider #4206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
mrubens
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
|
Let me know if I can help getting the tests to pass |
|
The compile error should be fixed, but I don't get the platform unit test failure. |
|
Ah ok, will try to figure it out separately. Thank you for the PR! |
|
@mollux can you please shoot me a discord DM at hrudolph? |
Related GitHub Issue
Closes: #
Description
The current implementation of LiteLLM doesn't take into account cached tokens (both write and read), resulting in incorrect cost calculation.
This PR stores the relevant information (taking into account the Anthropic only
cache_creation_input_tokens, see https://docs.litellm.ai/docs/completion/prompt_caching), and uses it during cost calculation and visualisation of the cached tokens.Test Procedure
note: depending on the model, the cost calculation can be wrong in liteLLM (e.g. for Anthropic models), as cache calculation has some quirks there too. This doesn't change the usefulness of supporting that cache info in Roo Code
Type of Change
srcor test files.Pre-Submission Checklist
npm run lint).console.log) has been removed.npm test).mainbranch.npm run changesetif this PR includes user-facing changes or dependency updates.Screenshots / Videos
Documentation Updates
Additional Notes
Get in Touch
Important
Adds cached token cost calculation to LiteLLM, updating model info and usage data reporting.
LiteLLMHandlerinlite-llm.ts.getLiteLLMModelsinlitellm.tsto includecacheWritesPriceandcacheReadsPrice.calculateApiCostOpenAIusage to include cache write and read tokens inlite-llm.ts.cacheWriteTokensandcacheReadTokenstoApiStreamUsageChunkinlite-llm.ts.This description was created by
for 3716053. You can customize this summary. It will automatically update as commits are pushed.